import Node from '../core/Node';

export default class extends Node {
    constructor(canvas, style, url) {
        super(canvas, style);
        this.img = new Image();
        this.img.src = url;
        this.rect = style.rect || [0, 0, this.img.width, this.img.height];
    }
    draw(painter) {
        painter.drawImage(
            this.img,
            this.left + this.rect[0],
            this.bottom + this.rect[1],
            this.rect[2],
            this.rect[3],
            this.left - this.rect[2] / 2,
            this.bottom - this.rect[3] / 2,
            this.rect[2],
            this.rect[3],
        );
    }
}
